using System;
using System.Configuration;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Reflection;

namespace FAS.Utilities
{
    public class Logs
    {
        public static void WriteToLogFile(string logMessage)
        {
            string strLogMessage = string.Empty;
            DateTime dtCurr = DateTime.Now;
            string sPath = Assembly.GetExecutingAssembly().Location;
            string sFile = Assembly.GetExecutingAssembly().ManifestModule.Name;
            sPath = sPath.Replace(sFile, "");

            string strLogFile = sPath + "log_" + DateTime.Now.ToString("yyyyMMdd") + ".txt";
            StreamWriter swLog;

            strLogMessage = string.Format("{0}: {1}", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), logMessage);

            if (!File.Exists(strLogFile))
            {
                swLog = new StreamWriter(strLogFile);
            }
            else
            {
                swLog = File.AppendText(strLogFile);
            }

            swLog.WriteLine(strLogMessage);
            swLog.WriteLine();

            swLog.Close();

        }
    }
}
